

package com.myapp.struts;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author Rodrigo
 */
@Entity
@Table(name = "AGENDA")
@NamedQueries({@NamedQuery(name = "Agenda.findByIdAgenda", query = "SELECT a FROM Agenda a WHERE a.idAgenda = :idAgenda")})
public class Agenda implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Column(name = "ID_AGENDA", nullable = false)
    private Integer idAgenda;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idAgenda")
    private Collection<Horario> horarioCollection;
    @JoinColumn(name = "CPF_DONO", referencedColumnName = "CPF")
    @ManyToOne
    private PessoaPersistente cpfDono;

    public Agenda() {
    }

    public Agenda(Integer idAgenda) {
        this.idAgenda = idAgenda;
    }

    public Integer getIdAgenda() {
        return idAgenda;
    }

    public void setIdAgenda(Integer idAgenda) {
        this.idAgenda = idAgenda;
    }

    public Collection<Horario> getHorarioCollection() {
        return horarioCollection;
    }

    public void setHorarioCollection(Collection<Horario> horarioCollection) {
        this.horarioCollection = horarioCollection;
    }

    public PessoaPersistente getCpfDono() {
        return cpfDono;
    }

    public void setCpfDono(PessoaPersistente cpfDono) {
        this.cpfDono = cpfDono;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idAgenda != null ? idAgenda.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Agenda)) {
            return false;
        }
        Agenda other = (Agenda) object;
        if ((this.idAgenda == null && other.idAgenda != null) || (this.idAgenda != null && !this.idAgenda.equals(other.idAgenda))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.myapp.struts.Agenda[idAgenda=" + idAgenda + "]";
    }

}
